package com.example.edu.Controller;

import com.example.edu.Dto.CourseCreateDtoG;
import com.example.edu.Dto.ListDtoG;
import com.example.edu.Dto.Return;
import com.example.edu.Entity.Course;
import com.example.edu.Service.CourseService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/course")
public class CourseController {
    @Resource
    CourseService courseService;

    @PostMapping("/create")
    public Return create(HttpServletRequest request,@RequestBody CourseCreateDtoG createData){
        return courseService.create(request,createData);
    }

    @PostMapping("/getList")
    public Return getList(HttpServletRequest request, @RequestBody ListDtoG listData){
        return courseService.getList(request,listData);
    }

    @PostMapping("/get")
    public Return get(@RequestBody Course course){
        return courseService.get(course);
    }

    @PostMapping("/delete")
    public Return delete(@RequestBody Course courseId){
        return courseService.delete(courseId);
    }

    @PostMapping("/update")
    public Return update(@RequestBody Course course){
        return courseService.update(course);
    }

    @PostMapping("/join")
    public Return join(HttpServletRequest httpServletRequest, @RequestBody Course invite_code){
        return courseService.join(httpServletRequest,invite_code);
    }

    @PostMapping("/out")
    public Return out(HttpServletRequest httpServletRequest, @RequestBody Course course_id){
        return courseService.out(httpServletRequest,course_id);
    }
}
